

import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.MalformedURLException;

public class CalculDeuxServeur {
	
	static String bank = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	final static String a = "AAAATAGA"; 
			//random(10000); //la chaine a
	final static String b = "AAAAAAAA";
	//random(10000); //la chaine b
	/*Les chaines sont en dur pour le moment, om pourra par la suite
	 * mettre 
	 */
	public static void main(String[] args){
		try {
			//for(int k = 0; k < 1; k++){
				CalculDeux obj = new CalculDeux(0,a,b);
				//String lol = "a";
			//	if(k == 1)
					//lol = "b";
				Naming.rebind("rmi://localhost:1143/Calcula", obj);
			//}
				obj = new CalculDeux(1,a,b);
				Naming.rebind("rmi://localhost:1143/Calculb", obj);
		}
		catch (RemoteException e){
			System.out.println(e);
			System.out.println("Remote problem while binding \"Hello\"-server.");	    
		} catch (MalformedURLException e){
			System.out.println("bad URL");
		}
		System.out.println("Servers for \"Calcul\" are up.");

		
	}
	
    public static String random(int n) {
        String output = "";
        for (int i = 0; i<n; i++) {
            output+= bank.charAt((int) Math.round(Math.random()*25));
        }
        return output;
    }
}
